home *** CD-ROM | disk | FTP | other *** search
/ Hottest 6 / Hottest 6 (1996)(PDSoft)[!].iso / software / programming / c / sipp / demo / planettest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-11-24  |  1.9 KB  |  90 lines

  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #include <sipp.h>
  5. #include <primitives.h>
  6. #include <shaders.h>
  7.  
  8.  
  9.  
  10. #define SUBDIVS  50
  11.  
  12. extern char *optarg;
  13.  
  14. main(argc, argv)
  15.     int    argc;
  16.     char **argv;
  17. {
  18.     Surf_desc   planet_surface;
  19.     Object     *planet;
  20.     FILE       *outfile;
  21.  
  22.     char    *imfile_name;
  23.     int      mode;
  24.     int      c;
  25.     int      size;
  26.  
  27.     imfile_name = "planet.ppm";
  28.     mode = PHONG;
  29.     size = 256;
  30.  
  31.     while ((c = getopt(argc, argv, "pgfls:")) != EOF) {
  32.         switch (c) {
  33.           case 'p':
  34.             mode = PHONG;
  35.             imfile_name = "planet.ppm";
  36.             break;
  37.  
  38.           case 'g':
  39.             mode = GOURAUD;
  40.             imfile_name = "planet.ppm";
  41.             break;
  42.  
  43.           case 'f':
  44.             mode = FLAT;
  45.             imfile_name = "planet.ppm";
  46.             break;
  47.  
  48.           case 'l':
  49.             mode = LINE;
  50.             imfile_name = "planet.pbm";
  51.             break;
  52.  
  53.           case 's':
  54.             size = atoi(optarg);
  55.             break;
  56.         }
  57.     }
  58.     
  59.     planet_surface.ambient = 0.4;
  60.     planet_surface.specular = 0.0;
  61.     planet_surface.c3 = 0.5;
  62.     planet_surface.color.red = 1.0;
  63.     planet_surface.color.grn = 0.0;
  64.     planet_surface.color.blu = 0.0;
  65.     planet_surface.opacity.red = 1.0;
  66.     planet_surface.opacity.grn = 1.0;
  67.     planet_surface.opacity.blu = 1.0;
  68.  
  69.     sipp_init();
  70.  
  71.     lightsource_create(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, LIGHT_DIRECTION);
  72.  
  73.     object_add_subobj(sipp_world, sipp_sphere(1.0, SUBDIVS, &planet_surface, 
  74.                                               planet_shader, WORLD)); 
  75.     object_rot_z(sipp_world, -1.2);
  76.     object_rot_x(sipp_world, 0.2);
  77.  
  78.     camera_params(sipp_camera, 0.0, 2.0, 0.0,  0.0, 0.0, 0.0,  
  79.                   0.0, 0.0, 1.0,  0.75);
  80.  
  81.     printf("Rendering, wait...");
  82.     fflush(stdout);
  83.  
  84.     outfile = fopen(imfile_name, "w");
  85.     render_image_file(size, size, outfile, mode, 3);
  86.     printf("Done.\n");
  87.     
  88.     exit(0);
  89. }
  90.